/*
 * @Author: wuqingchun
 * @Date: 2024-07-09 21:08:57
 * @Description: 多进程epoll机制模拟
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-07-10 10:32:32
 */
#ifndef __MULTI_PROCESS_EPOLL_H__
#define __MULTI_PROCESS_EPOLL_H__

#include <cstddef>
#include <cstdint>

#include <fcntl.h>           /* For O_* constants */
#include <sys/stat.h>        /* For mode constants */
#include <semaphore.h>

class CMPEpoller
{
public:
    struct MP_EP_OBJECT
    {
        uint32_t uiObjectID;
    };
public:
    CMPEpoller();

    int32_t Create(const char* pcName, size_t ulSize);

    int32_t Wait(MP_EP_OBJECT* pstObjects, uint32_t uiMaxObject, int32_t iTimeout);

    int32_t Post(uint32_t uiObjectID);

    void Close();

private:
    char szName[256];
    sem_t* m_pstSem = nullptr;
};


#endif //__MULTI_PROCESS_EPOLL_H__